<?php
/**
*
*总部信息统计
*
*/
require('../include/init.php');
date_default_timezone_set('Asia/Shanghai');
$mysqli=mysql::getIns();



$maxtime=time();
$mintime=$maxtime-10*60;
$t = time();
$start = mktime(0,0,0,date("m",$t),date("d",$t),date("Y",$t));
$end = mktime(23,59,59,date("m",$t),date("d",$t),date("Y",$t));

//现在人数
$sql="select count(*) from alldev where whitelist <> '1' and timestamp > $mintime and timestamp < $maxtime and shop <> 'Audi City BeiJing';";
//今天人数
$sql .="select count(*) from alldev where whitelist <> '1' and timestamp > $start and timestamp < $end and shop <> 'Audi City BeiJing';";
//首次
$sql .="select count(*) from alldev where whitelist <> '1' and visittimes=1 and timestamp > $mintime and timestamp < $maxtime and shop <> 'Audi City BeiJing';";
//多次
$sql .="select count(*) from alldev where whitelist <> '1' and visittimes <> 1 and timestamp > $mintime and timestamp < $maxtime and shop <> 'Audi City BeiJing';";
//销售区
$sql .="select count(*) from alldev where whitelist <> '1' and timestamp > $mintime and timestamp < $maxtime and shop <> 'Audi City BeiJing' and area in ('销售区','展厅区','精品区');";
//售后
$sql .="select count(*) from alldev where whitelist <> '1' and isOL=1 and timestamp > $mintime and timestamp < $maxtime and shop <>'Audi City BeiJing';";
//历史
$sql .="select count(*) from alldev where whitelist <> '1' and shop <>'Audi City BeiJing'";
//一次执行多条
$data=$mysqli->getDuo($sql);


$allnow=$data[0];
$allday=$data[1];
$first=$data[2];
$second=$data[3];
$sale=$data[4];
$service=$allnow-$sale;
$login=$data[5];
$nolog=$allnow-$login;
$history=$data[6];

//采用redis来进行缓存

$redis = new Redis();
  //连接服务器
  $redis->connect("localhost");
  //授权
  $redis->auth("redis=pwd@2016");

$redis->hmset('National_Main', array('allnow' =>$allnow, 'allday'=>$allday,
'first'=>$first,'second'=>$second,'sale'=>$sale,'service'=>$service,'login'=>$login,
'nolog'=>$nolog,'history'=>$history));
